import psycopg2
from psycopg2 import pool

# =========================
# 数据库配置
# =========================
db = psycopg2.pool.SimpleConnectionPool(
    minconn=10,
    maxconn=100,
    host="49.233.41.129",
    database="chatbot",
    user="root",
    password="15671040800q",
    port=5433
)


# 打印连接池配置
def print_pool_status():
    print(f"当前连接池配置:")
    print(f" - 最小连接数 (minconn): {db.minconn}")
    print(f" - 最大连接数 (maxconn): {db.maxconn}")
    print(f" - 当前空闲连接数: {len(db.pool)}")
    print(f" - 当前占用连接数: {len(db.used)}")
    print("-" * 40)


# 调用示例
print_pool_status()
